home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / cmds / pmake / lst / RCS / lst.h,v < prev    next >
Encoding:
Text File  |  1992-05-19  |  4.1 KB  |  140 lines

  1. head     1.10;
  2. branch   ;
  3. access   ;
  4. symbols  ;
  5. locks    ; strict;
  6. comment  @ * @;
  7.  
  8.  
  9. 1.10
  10. date     88.11.17.20.51.41;  author adam;  state Exp;
  11. branches ;
  12. next     ;
  13.  
  14.  
  15. desc
  16. @@
  17.  
  18.  
  19.  
  20. 1.10
  21. log
  22. @checked in with -k by kupfer at 92.05.18.17.32.32.
  23. @
  24. text
  25. @/*-
  26.  * lst.h --
  27.  *    Header for using the list library
  28.  *
  29.  * Copyright (c) 1988 by University of California Regents
  30.  *
  31.  * Permission to use, copy, modify, and distribute this
  32.  * software and its documentation for any purpose and without
  33.  * fee is hereby granted, provided that the above copyright
  34.  * notice appears in all copies.  Neither the University of California nor
  35.  * Adam de Boor makes any representations about the suitability of this
  36.  * software for any purpose.  It is provided "as is" without
  37.  * express or implied warranty.
  38.  *
  39.  * $Id: lst.h,v 1.10 88/11/17 20:51:41 adam Exp $ SPRITE (Berkeley)
  40.  */
  41. #ifndef _LST_H_
  42. #define _LST_H_
  43.  
  44. #include    <sprite.h>
  45.  
  46. /*
  47.  * basic typedef. This is what the Lst_ functions handle
  48.  */
  49.  
  50. typedef    struct    Lst    *Lst;
  51. typedef    struct    LstNode    *LstNode;
  52.  
  53. #define    NILLST        ((Lst) NIL)
  54. #define    NILLNODE    ((LstNode) NIL)
  55.  
  56. /*
  57.  * NOFREE can be used as the freeProc to Lst_Destroy when the elements are
  58.  *    not to be freed.
  59.  * NOCOPY performs similarly when given as the copyProc to Lst_Duplicate.
  60.  */
  61. #define NOFREE        ((void (*)()) 0)
  62. #define NOCOPY        ((ClientData (*)()) 0)
  63.  
  64. #define LST_CONCNEW    0   /* create new LstNode's when using Lst_Concat */
  65. #define LST_CONCLINK    1   /* relink LstNode's when using Lst_Concat */
  66.  
  67. /*
  68.  * Creation/destruction functions
  69.  */
  70. Lst          Lst_Init();            /* Create a new list */
  71. Lst              Lst_Duplicate();      /* Duplicate an existing list */
  72. void          Lst_Destroy();    /* Destroy an old one */
  73.  
  74. int              Lst_Length();            /* Find the length of a list */
  75. Boolean          Lst_IsEmpty();    /* True if list is empty */
  76.  
  77. /*
  78.  * Functions to modify a list
  79.  */
  80. ReturnStatus      Lst_Insert();            /* Insert an element before another */
  81. ReturnStatus      Lst_Append();            /* Insert an element after another */
  82. ReturnStatus      Lst_AtFront();        /* Place an element at the front of
  83.                      * a lst. */
  84. ReturnStatus      Lst_AtEnd();            /* Place an element at the end of a
  85.                      * lst. */
  86. ReturnStatus      Lst_Remove();            /* Remove an element */
  87. ReturnStatus      Lst_Replace();    /* Replace a node with a new value */
  88. ReturnStatus      Lst_Move();            /* Move an element to another place */
  89. ReturnStatus      Lst_Concat();            /* Concatenate two lists */
  90.  
  91. /*
  92.  * Node-specific functions
  93.  */
  94. LstNode          Lst_First();            /* Return first element in list */
  95. LstNode          Lst_Last();            /* Return last element in list */
  96. LstNode          Lst_Succ();            /* Return successor to given element */
  97. LstNode          Lst_Pred();            /* Return predecessor to given
  98.                      * element */
  99. ClientData      Lst_Datum();            /* Get datum from LstNode */
  100.  
  101. /*
  102.  * Functions for entire lists
  103.  */
  104. LstNode          Lst_Find();            /* Find an element in a list */
  105. LstNode          Lst_FindFrom();    /* Find an element starting from
  106.                      * somewhere */
  107. LstNode              Lst_Member();            /* See if the given datum is on the
  108.                      * list. Returns the LstNode containing
  109.                      * the datum */
  110. int              Lst_Index();            /* Returns the index of a datum in the
  111.                      * list, starting from 0 */
  112. void          Lst_ForEach();    /* Apply a function to all elements of
  113.                      * a lst */
  114. void              Lst_ForEachFrom();      /* Apply a function to all elements of
  115.                      * a lst starting from a certain point.
  116.                      * If the list is circular, the
  117.                      * application will wrap around to the
  118.                      * beginning of the list again. */
  119. /*
  120.  * these functions are for dealing with a list as a table, of sorts.
  121.  * An idea of the "current element" is kept and used by all the functions
  122.  * between Lst_Open() and Lst_Close().
  123.  */
  124. ReturnStatus      Lst_Open();            /* Open the list */
  125. LstNode          Lst_Prev();            /* Previous element */
  126. LstNode          Lst_Cur();            /* The current element, please */
  127. LstNode          Lst_Next();            /* Next element please */
  128. Boolean          Lst_IsAtEnd();    /* Done yet? */
  129. void          Lst_Close();            /* Finish table access */
  130.  
  131. /*
  132.  * for using the list as a queue
  133.  */
  134. ReturnStatus      Lst_EnQueue();    /* Place an element at tail of queue */
  135. ClientData      Lst_DeQueue();    /* Remove an element from head of
  136.                      * queue */
  137.  
  138. #endif _LST_H_
  139. @
  140.